﻿using System;
namespace Producers.Ehr.Xtee.Riik.Ee.Producer.Ehr {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="vallasvara_piirangudParingType", Namespace="http://producers.ehr.xtee.riik.ee/producer/ehr", Target=typeof(VallasvaraPiirangudParingType))]
    public class VallasvaraPiirangudParingTypeSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IVallasvaraPiirangudParingType clazz;
        
        public VallasvaraPiirangudParingTypeSerializer(IVallasvaraPiirangudParingType clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("EHIT_ID");
            if (clazz.EHITID!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.EHITID))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : EHITID");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("EHR_KOOD");
            if (clazz.EHRKOOD!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.EHRKOOD))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : EHRKOOD");
            }
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="EHIT_ID") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>vallasvara_piirangudParingType>EHIT_ID");
                }
                clazz.EHITID = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("EHIT_ID")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>vallasvara_piirangudParingType>EHIT_ID", Reader.LocalName);
            }
            if (Reader.LocalName=="EHR_KOOD") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>vallasvara_piirangudParingType>EHR_KOOD");
                }
                clazz.EHRKOOD = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("EHR_KOOD")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>vallasvara_piirangudParingType>EHR_KOOD", Reader.LocalName);
            }
        }
    }
}
